package com.qf.edu.service.impl;

import com.qf.edu.dao.DrugsGt;
import com.qf.edu.dao.impl.DrugsGtImpl;
import com.qf.edu.entity.Drugs;
import com.qf.edu.entity.Drugsgrant;
import com.qf.edu.service.DrugsGtService;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author:huayuzhuo
 * @email:2798866329@qq.com
 * @desc:DrugsGtService接口实现类
 * @datatime: 2022/5/29 12:16
 */
public class DrugsGtServiceImpl implements DrugsGtService {
    DrugsGt drugsGt = new DrugsGtImpl();

    @Override
    public String drugsGtS(Drugsgrant drugsgrant) {
        int i = drugsGt.drugsG(drugsgrant);
        if (i == 1){
            return "提交通过";
        } else {
            return "提交失败";
        }
    }

    @Override
    public int drugskp(Drugsgrant drugsgrant) {
        Drugs drugs = drugsGt.drugsGets(drugsgrant);
        int number = drugs.getNumber() - drugsgrant.getNumber();

        int drugskp = drugsGt.drugskp(number, drugsgrant);
        if (drugskp == 1){
            return drugskp;
        }
        return 0;
    }

    @Override
    public int drugsGet(Drugsgrant drugsgrant) {
        Drugs drugs = drugsGt.drugsGets(drugsgrant);
        if (drugs != null){
            return drugs.getNumber();
        }
        return 0;
    }

}
